package Com.Ring.TradingMobile.Lib;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.ksoap2.HeaderProperty;

public class Session {
	private static HeaderProperty mSessionHeader = null;
	public static boolean IsLogin = false;
	public static int currentSubAccountPossition = 0;
	public static String currentSubAccount;
	public static String custAccount;

	public static List<String> subCustAccounts = new ArrayList<String>();
	public static boolean isFirstTime = false;
	public static boolean isFirstTimeOrderStatus = false;
	public static Hashtable<String, JSONArray> subPermissionAccount = new Hashtable<String, JSONArray>();

	public static LinkedList<HeaderProperty> GetSession() {

		LinkedList<HeaderProperty> reqHeaders = new LinkedList<HeaderProperty>();
		if (mSessionHeader != null) {
			reqHeaders.add(new HeaderProperty("Cookie", mSessionHeader
					.getValue()));
		}
		return reqHeaders;
	}

	public static void SetSession(List<HeaderProperty> respHeaders) {

		for (HeaderProperty hp : respHeaders) {
			if (hp.getKey().equalsIgnoreCase("set-cookie")) {
				mSessionHeader = hp;
				break;
			}
		}
	}

	public static void ClearSession() {
		mSessionHeader = null;
		IsLogin = false;
		isFirstTime = false;
	}
}
